﻿using System;
using System.IO;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;

namespace JuCloudy.Framework.Storge
{
    public class LocalSetting
    {
        private static System.IO.IsolatedStorage.IsolatedStorageSettings AppSetting =
            System.IO.IsolatedStorage.IsolatedStorageSettings.ApplicationSettings;
        public static void Set(String Key, String Value)
        {
            if (AppSetting.Contains(Key))
            {
                AppSetting[Key] = Value;
            }
            else
            {
                AppSetting.Add(Key, Value);
            }
            AppSetting.Save();
        }

        public static String Get(String Key)
        {
            if (AppSetting.Contains(Key))
                return AppSetting[Key].ToString();
            else
                return null;
        }

        public static void SetStream(String Key, Stream Value)
        {
            if (AppSetting.Contains(Key))
            {
                AppSetting[Key] = Value;
            }
            else
            {
                AppSetting.Add(Key, Value);
            }
            AppSetting.Save();
        }

        public static Stream GetStream(String Key)
        {
            if (AppSetting.Contains(Key))
                return (Stream)AppSetting[Key];
            else
                return null;
        }

        public static void Remove(String Key){
            if(AppSetting.Contains(Key))
                AppSetting.Remove(Key);
        }

        public static bool Contains(String Key)
        {
            return AppSetting.Contains(Key);
        }

        public static void Clear()
        {
            AppSetting.Clear();
        }
    }
}
